<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="pu" uri="/WEB-INF/tld/pageutil.tld" %>
<%@taglib prefix="mu" uri="/WEB-INF/tld/mallutil.tld" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib prefix="pageable" uri="/WEB-INF/tld/pageable.tld" %>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@ taglib prefix="yaodian100" uri="http://www.yaodian100.com/jsp/yaodian100" %>
<c-rt:set var="imgDomain"><%=ServerValue.getImgDomain()%></c-rt:set>
<link rel="stylesheet" href="/css/yaodian100_footer_v3.css" type="text/css" />
<link rel="stylesheet" href="/css/yaodian100_header_v5.css" type="text/css" />
<link rel="stylesheet" href="/css/yaodian100_v2.css" type="text/css" media="screen,print" />
<script type="text/javascript" src="/js/rate_scores.js"></script><!-- 评价星星用 -->
<script type="text/javascript">
jQuery(function(){
	$(":input[id*=orderComtSubject_]").keyup(function(){
		if($(this).val().length>15){
			alertDialog('评价标题', "已超过字数限制");
			$(this).val($(this).val().substring(0,15));
		}
		$('#wordTitleCountDown_').html(15-$(this).val().length);
	});
	$(":input[id*=contentdata_]").keyup(function(){
		if($(this).val().length>135){
			alertDialog('评价心得', "已超过字数限制");
			$(this).val($(this).val().substring(0,135));
		}
		$('#wordCountDown_').html(135-$(this).val().length);
	});
	
	$("#m2dialog").dialog({
		bgiframe: true,
		width:300,
		modal: true,
		autoOpen: false
	});
	// 大型 input、textarea 表格 mouseover 示意效果
	$('.ipt-w20-s').find('input').bind('focus blur', function(){ $(this).parent().toggleClass('on-f') })
	$('.txtarea').find('textarea').bind('focus blur', function(){ $(this).parent().toggleClass('on-f') })
	// $('.opinion-tb').find('th:last, td:last').css('border-bottom', 0);
	
	$(":input[id*=no_comment_btn_]").click(function(){
		$("#spandialog").text($("#prodName").text());
		$("#nocomment_").val('Y');
		$("#m2dialog").dialog('open');
		$("#m2dialog").val($(this).attr('id'));
		return false;
	});
	$("#m2_ok").click(function(){
		$("#m2dialog").dialog('close');
		var text = $("#m2dialog").val().split('_')[3];
		$("#comment_"+text).hide();
		$("#none_comment_msg").show();
		$("#div_save_comment").hide();
	});
	$("#m2_cancel").click(function(){
		$("#nocomment_").val('');
		$("#m2dialog").dialog('close');
	});
	
	$("#save_comment").click(function() {	
		
		var error='';
		$("input[id*='prodsize_']").each(function(i){
			if(this.checked){
				$("#sizedata_").val($(this).attr("value"));
			}	
		});
		
		$("input[id*='titleTip_']").each(function(i){
			$("#titleTip_"+(i+1)).hide();
			$("#orderComtScoreTip_"+(i+1)).hide();
			$("#sizedataTip_"+(i+1)).hide();
			$("#contentdataTip_"+(i+1)).hide();
		});
		
		$("input[id*='orderComtSubject_']").each(function(i){
			$("#titleTip_").hide();
			if($("#nocomment_").val()==''){
			if($(this).val().length==0){
					$("#titleTip_").show();
					error+="notitle";
				}
			}
		});
		$("input[id*='orderComtScore_']").each(function(i){
			$("#orderComtScoreTip_").hide();
			if($("#nocomment_").val()==''){
			if($(this).val().length==0){
				$("#orderComtScoreTip_").show();
					error+="notitle";
				}
			}
		});
		
		$("input[id*='sizedata_']").each(function(i){
			$("#sizedataTip_").hide();
			if($("#nocomment_").val()==''){
			if($(this).val().length==0){
				$("#sizedataTip_").show();
					error+="notitle";
				}
			}
		});
		$(":input[id*=contentdata_]").each(function(i){
			$("#contentdataTip_").hide();
			if($("#nocomment_").val()==''){
				if($(this).val().length==0){
					$("#contentdataTip_").show();
					error+="nocontent";
				}
			}
		});
		
		if(error!=''){
			//alert(error);
		}else{
			$("#orderCommentForm").submit();
		}
		return false;
	});
});
$(function(){ 
	$('#current_location').html(' > 对商品进行评价');
}); 
</script>
  <div id="main" class="member-index">
  <div class="content full">
  <h2>对商品进行评价<em class="txt-gy txt-s">&nbsp;(请发表原创并对其它用户有参考价值的商品评价，审核通过后您可获得一定积分奖励喔！)</em></h2>
<form id="orderCommentForm" name="orderCommentForm" method="post" action="<c-rt:url value="updatecomment.do"/>">
<p class="opinion-tb-none" id="none_comment_msg" style="display:none;"><span class="txt-L">没有要评价的商品了...</span><br /><a href="/ecmall/member/myOrder/showOrders.do?t=T&p=1">返回我的订单</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">去首页逛逛</a></p>
<input type="hidden" name="mainProductId" value="${orderComment.mainProductId }"/>
  <table class="opinion-tb">
<!-- first row -->
  <tr id="comment_${status.count}">
  	<th>
        <a href="/ecmall/product/product.do?productId=${orderComment.mainProductId}" target="_blank">
        <img width="135" height="135" alt="" src="${imgDomain}/PImg/${pu:substring(orderComment.productId, 0,4) }/${orderComment.productId}/${orderComment.productId}_m135.jpg" onError="this.src='/PImg/blank_135.gif'">
        </a>
        <strong><a id="prodName" href="/ecmall/product/product.do?productId=${orderComment.productId}" target="_blank">${orderComment.productName}</a></strong>
        <span class="txt-gy">${orderComment.specName}</span><br />
        <button id="no_comment_btn_">暂不评价</button>
         <input type="text" id="nocomment_" name="nocomment" value=""  style="display: none;"/>
    </th>
    <td>
    	<table class="comment-area">
        <tr class="comment-title-row">
            <th><strong><span class="txt-rd">*</span> 标题：</strong></th>
            <td> 
            <input type="text" name="orderComtCmid" value="${orderComment.cmid}" style="display: none;">
            <input type="text" name="orderComtOrderId" value="${orderComment.orderId}" style="display: none;">
            <input type="text" name="orderComtProductId" value="${orderComment.productId}" style="display: none;">
 			<input type="text" name="orderComtOrderDetailId" value="${orderComment.orderDetailId}" style="display: none;">
            <strong class="ipt-w20-s"><input type="text" id="orderComtSubject_" name="orderComtSubject" value="${orderComment.subject}" /></strong>(还可以输入<em class="txt-rd"><span id="wordTitleCountDown_">15</span></em>个字)
	   		<br>
	    	<span id="titleTip_" class="msg rn" style="display: none;">请输入标题</span>
	    </td>
        </tr>
        <tr>
            <th><strong><span class="txt-rd">*</span> 评分：</strong></th>
            <td>
			<div class="goods-comm">
				<div class="goods-comm-stars">
					<div id="rate-comm-1" class="rate-comm">
                    </div>
                     <input type="text" name="orderComtScore" id="orderComtScore_1" value="${orderComment.score}" style="display: none;">
				</div>
			</div>
            <p class="txt-gy to-feedback">(如另有订单、物流等问题，可<a href="/ecmall/help/complain/main.do" target="_blank">点此提交您的投诉与建议</a>)</p>
            <span style="clear:left;display:block"><span id="orderComtScoreTip_" class="msg rn" style="display: none;">请对商品进行评分</span></span>
            </td>
            </tr>
            <c-rt:if test="${not empty prodInfoMap and prodInfoMap[orderData[0]] eq 'Y'}">
        <tr>
        	<th><strong><span class="txt-rd">*</span> 尺码：</strong></th>
            <td class="choose-size">
            	<label><input type="radio" id="prodsize_${status.count}" name="prodsize_${status.count}" value="A" <c-rt:if test="${orderComment.size eq 'A'}">checked="checked"</c-rt:if>/>偏大</label>
                <label><input type="radio" id="prodsize_${status.count}" name="prodsize_${status.count}" value="B" <c-rt:if test="${orderComment.size eq 'B'}">checked="checked"</c-rt:if>/>合适</label>
                <label><input type="radio" id="prodsize_${status.count}" name="prodsize_${status.count}" value="C" <c-rt:if test="${orderComment.size eq 'C'}">checked="checked"</c-rt:if>/>偏小</label><br />
                <input type="text" id="sizedata_${status.count}" name="sizedata" value="${orderComment.size}" style="display: none;"/>
                <span style="display:block;"><span id="sizedataTip_" class="msg rn" style="display: none;">请对商品的尺码进行评分</span></span>
            </td>
        </tr>
        </c-rt:if>
        <c-rt:if test="${empty prodInfoMap or ( not empty prodInfoMap and  prodInfoMap[orderData[0]] eq 'N')}">
        	<input type="hidden" id="sizedata_${status.count}" name="sizedata" value="#"/>
        	<span style="display:block;"><span id="sizedataTip_${status.count}" class="msg rn" style="display: none;"></span></span>
        </c-rt:if>
        <tr>
        	<th valign="top"><strong><span class="txt-rd">*</span> 心得：</strong></th>
            <td>
            	<div class="txtarea">
            	<textarea rows="3" name="contentdata" id="contentdata_">${orderComment.content}</textarea><br />
                </div>
                 <span style="margin-left:10px">(还可以输入<em class="txt-rd"><span id="wordCountDown_">135</span></em>个字</span>)
                <span style="display:block;"><span id="contentdataTip_" class="msg rn" style="display: none;">请输入心得</span></span>
            </td>
        </tr>
        </table>
    </td>
  </tr>
  </table>
  <div id="div_save_comment" style="text-align:center; margin-top:30px"><a class="btn-mid" id="save_comment" href="javascript:void(0);">提交评价</a></div>
  </div>
  </div>
</form>

<div id="m2dialog" title="系统提示"  class="alert-caution" style="display:none"  value="">
<p><br />若您已经填写了对该商品的评价的话，内容将不会被保存，<br>下次评价需重新填写。<br><br>您确认暂不评价<span class="txt-rd" id="spandialog"></span>？</p>
<div style="text-align:center;"><a href="javascript:;" class="btn-mid" id="m2_ok">确定</a>
<a href="javascript:;" class="btn-mid" id="m2_cancel">取消</a>
</div>
